<template>
    <login @fun="login"></login>
</template>

<script>
    import login from '../subcomponents/login.vue'
    import {Toast} from 'mint-ui'
    export default {
       components:{
           login
       },
        methods:{
           login(option){
                this.$http.post('http://127.0.0.1:3002/checkLogin',option,{emulateJSON:true}).then((result)=>{
                    if(result.body.status == 0){
                        Toast('登录成功');
                        var user = result.body.message[0].username;
                        var email = result.body.message[0].email;
                        var id = result.body.message[0].id;
                        this.$store.commit('getUser',{id:id,user:user,email:email});
                        this.$router.push('/');
                    }else{
                        Toast('登录失败');
                    }

                });
           }
        }
    }
</script>

<style scoped>

</style>